package 力扣._00周赛._376周赛.问题1;

import java.util.HashSet;
import java.util.Set;

class Solution {
    public int[] findMissingAndRepeatedValues(int[][] grid) {
        int n = grid.length;
        Set<Integer> set = new HashSet<>();
        int[] r = new int[2];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (set.contains(grid[i][j])) {
                    r[0] = grid[i][j];
                    break;
                } else
                    set.add(grid[i][j]);
            }
            if (r[0] > 0)
                break;
        }
        for (int i = 1; i <= n * n; i++) {
            if (!set.contains(i)) {
                r[1] = i;
                break;
            }
        }
        return r;

    }
}